const router = require('koa-router')()
import Sys from '../controller/Sys'
import Error from '../controller/Error'
import Performance from '../controller/Performance'
import Log from '../controller/Log'
import WeiXin from '../controller/WeiXin'
import Sign from '../controller/Sign'
var EventEmitter = require('events').EventEmitter; 
var event = new EventEmitter(); 
import test from '../controller/test'
console.log(Sys)
// const index = require('./routes/index')
router
.prefix('/server')
.get('/sign/set',Sign.set)
.get('/sign/get', Sign.get)

.post('/editAppInfo', Sys.editAppInfo)
.get('/apps', Sys.apps)
.get('/getApp', Sys.getApp)
.post('/configure',Sys.configure)
.get('/debugjs',Sys.debugjs)
.get('/wxToken',WeiXin.wxToken)
.post('/wxToken',WeiXin.notice)
.post('/sendLog',Log.send)
.get('/log/listen',Log.listen)

.get('/performance/reportSimple',Performance.reportSimple)
.post('/performance/report',Performance.report)
.get('/performance/list',Performance.list)

.get('/error/reportSimple',Error.reportSimple)
.post('/error/report',Error.report)
.get('/error/list',Error.list)
.io = (io)=>{
    console.log('88888888888')
    console.log(this)
    io.on('connection', function (socket) {
       console.log('connected0000000');
    });
    // console.log('event.on listen')
   test.initCollectio(io)
    // test.on('listen', function() { 
    //     io.sockets.emit('receiveMsg',{a:'receiveMsg'})
    //     console.log('listen test 事件触发'); 
    // });
    return io;
}

//router.
module.exports = router